package com.qiyu.jvm.gc.cms;

/**
 * @Author linhao
 * @Date created in 6:38 下午 2021/2/5
 */
public class GCDemo {

    public static void main(String[] args) throws InterruptedException {
        while (true) {
            System.out.println("模拟垃圾回收过程中，对象从栈进入到堆当中");
            byte[] b_2M = new byte[2 * 1024 * 1024];
            b_2M = new byte[2 * 1024 * 1024];
            b_2M = new byte[2 * 1024 * 1024];
            b_2M = null;

            byte[] b_128k = new byte[128 * 1024];

            byte[] b_2M_1 = new byte[2 * 1024 * 1024];
            b_2M_1 = new byte[2 * 1024 * 1024];
            b_2M_1 = new byte[2 * 1024 * 1024];
            b_2M_1 = null;

            System.out.println("此时因该已经占用了 12m + 128k 内存");
            Thread.sleep(500);
            System.out.println("================================");
        }
    }
}
